const Router = require('koa-router')()
const mongoose = require('mongoose')

// 评价后端需做两个事 ,一个是将已完成的该订单删除,另一个是 创建那个商品的评价(不做)
Router.post('/', async (ctx) => {
  const phone = ctx.session.phone
  const orderNumber = ctx.request.body.orderNumber
  const table = mongoose.model('bee')
  try {
    await table.updateOne({ phone }, { $pull: { waitPaygoods: { orderNumber: orderNumber } } }, { useFindAndModify: false })
    ctx.body = {
      code: 200,
      msg: '成功'
    }
  } catch (err) {
    ctx.body = {
      code: 400,
      msg: '异常'
    }
  }
})
module.exports = Router
